<template>
  <div>
    <!-- 需求计划汇总查询N+1 -->
    <TopFilter :list="topFilterList" :cols="3" @filterChange="changeHandle" @onCollapse="collapseHandle" :labelWidth="110"></TopFilter>

    <FilterTable
      ref="table"
      columnsRef="qjhActualSalesChange"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => (this.columns = columns)"
    >
      <template slot="controls" slot-scope="props"> </template>
    </FilterTable>

    <BaseDialog :visible.sync="issearch" :title="'详情'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <ownerSeacher :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>
  </div>
</template>
<script>
import ownerSeacher from './ownerSeacher';
export default {
  name: 'TemplateDistribution',
  data() {
    this.BaseTable = null;
    return {
      topFilterList: this.createdFrom(),
      columns: this.createdTable(),
      fetchParams: {},
      fetchApi: () => {},
      formData: {},
      issearch: false
    };
  },
  components: {
    ownerSeacher
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created() {},
  methods: {
    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'jxsdm1',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: 'VIN号',
          fieldName: 'vin',
          placeholder: '请输入'
        },
        {
          type: 'RANGE_DATE',
          label: '实销上报日期',
          fieldName: 'sxsbrq',
          placeholder: '请选择',
          initialValue: []
        },
        {
          type: 'INPUT',
          label: '零售订单号',
          fieldName: 'lsddh',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'khmc',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '发票号',
          fieldName: 'fph',
          placeholder: '请输入'
        },
        {
          type: 'RANGE_DATE',
          label: '税控系统销售日期',
          fieldName: 'skxtxsrq',
          placeholder: '请选择',
          initialValue: []
        },
        {
          type: 'RANGE_DATE',
          label: 'CMS系统销售日期',
          fieldName: 'cms系统销售日期',
          placeholder: '请选择',
          initialValue: []
        },
        {
          type: 'INPUT',
          label: '异常原因',
          fieldName: 'ycyy',
          placeholder: '请输入'
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '经销商代码',
          dataIndex: 'jxsdm',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '经销商名称',
          dataIndex: 'jxsmc',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '事业部',
          dataIndex: 'syb',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '办事处',
          dataIndex: 'bsc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '零售单号',
          dataIndex: 'lsdh',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '客户名称',
          dataIndex: 'khmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'VIN',
          dataIndex: 'vin',align: 'center',
          width: 180,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'CMS开票时间',
          dataIndex: 'cmskpsj',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'CMS交车时间',
          dataIndex: 'cmsjcsj',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '实销上报时间',
          dataIndex: 'sxsbsj',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true
        },
        {
          title: '税控开票时间',
          dataIndex: 'skkpsj',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '税控销售日期',
          dataIndex: 'skxsrq',
          sorter: true,
          filter: true,
          filterType: 'input',
          editRequired: true
        },
        {
          title: '异常天数',
          dataIndex: 'ycts',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '异常原因',
          dataIndex: 'ycyy',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    selectChangeHandle(row) {},
    seacherFun() {
      this.issearch = true;
    },
    async addHandle(type) {
      if (type == 1) {
        await this.$confirm('是否通过?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(async () => {})
          .catch(() => {});
      } else {
        this.isreject = true;
      }
    },
    changeHandle(params) {
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    editHandle(data) {
      this.visible = true;
    },
    emitcloseHandler() {
      this.visible = false;
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    }
  }
};
</script>
